using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WOWEquipOptimizer
{
    /// <summary>
    /// load chars from file or url
    /// </summary>
    public partial class CharParseDialog : Form
    {
        private string m_FileName = string.Empty;
        public CharParseDialog()
        {
            InitializeComponent();
        }
        public string GetURL()
        {
            if (m_FileName != string.Empty) return m_FileName;
            else return urlTextBox.Text;
        }
        private void LoadEquipButton_Click(object sender, EventArgs e)
        {
            openEquipDialog.Filter = "xef files (*.xef)|*.xef|All files (*.*)|*.*";
            openEquipDialog.FilterIndex = 1;
            openEquipDialog.RestoreDirectory = true;
            if (openEquipDialog.ShowDialog() == DialogResult.OK)
            {
                m_FileName = openEquipDialog.FileName;
                if (m_FileName != string.Empty)
                {
                    this.DialogResult = DialogResult.OK;
                }
                else this.DialogResult = DialogResult.Cancel;
                this.Close();
            }

        }

        private void FormClosedEvent(object sender, FormClosedEventArgs e)
        {
            if (m_FileName == string.Empty && urlTextBox.Text.Length == 0)
            {
                this.DialogResult = DialogResult.Cancel;
            }
        }
    }
}